package com.test.textGame.controller;

import com.test.textGame.dto.Score;
import com.test.textGame.vo.GameCommitVO;
import com.test.textGame.service.ScoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;

@RestController
@RequestMapping("/game")
public class TextGameController {

    @Autowired
    private ScoreService scoreService;

    /**
     * 提交成绩
     */
    @PostMapping("/play")
    public Score play(@Valid @RequestBody GameCommitVO vo){
        synchronized (TextGameController.class) {
            return scoreService.play(vo);
        }
    }

}
